<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>代理模式</title>
	</head>
	<body>
		<script>
			let o = {
				name: "张三",
				age: 18
			}
			let obj = new Proxy(o, {
				get: function(target, propKey, receiver) {
					console.log(target, propKey, receiver)
					console.log(`getting ${propKey}!`);
					return Reflect.get(target, propKey, receiver);
				},
				set: function(target, propKey, value, receiver) {
					console.log(target, propKey, receiver)
					console.log(`setting ${propKey}!`);
					return Reflect.set(target, propKey, value, receiver);
				}
			});
			obj.name = "李四";
			console.log(obj.name);
		</script>
	</body>
</html>
